def evalRPN(tokens):
    stack = []
    for token in tokens:
        try:
            stack.append(int(token))
        except:
            num2 = stack.pop()
            num1 = stack.pop()
            stack.append(evaluate(num1, num2, token))
    return stack[0]

def evaluate(num1, num2, op):
    if op == "+":
        return num1 + num2
    elif op == "-":
        return num1 - num2
    elif op == "*":
        return num1 * num2
    elif op == "/":
        return int(num1 / float(num2))

print(evalRPN(input().split(" ")))